package com.infoland.afanmall.base.fragment;

import android.widget.LinearLayout;

import com.infoland.afanmall.R;
import com.infoland.afanmall.model.guiGe.entity.ViewHolder;
import com.infoland.afanmall.base.dialog.BaseNiceDialogFragment;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.base.util.UserKit;
import com.infoland.afanmall.model.my.activity.PhoneRegisActivity;
import com.infoland.afanmall.model.my.dialog.OpenPhone;


import butterknife.BindView;

/**
 * 手机登陆
 * 手机注册
 * 微信登陆
 */

public class LoginDialogFragment extends BaseNiceDialogFragment {
    @BindView(R.id.login_ll_phone)
    LinearLayout loginLlPhone;
    @BindView(R.id.register_ll_phone)
    LinearLayout registerLlPhone;
    @BindView(R.id.login_img)
    LinearLayout loginImg;
    public com.infoland.afanmall.model.my.fragment.MyCenterFragment myCenterFragment;

    @Override
    public int intLayoutId() {
        return R.layout.open_login;
    }

    @Override
    public void convertView(ViewHolder holder, BaseNiceDialogFragment dialog) {
        addLinstener();
    }

    private void addLinstener() {

        /***手机登陆**/
        loginLlPhone.setOnClickListener(v -> {
            this.dismiss();
            showPhoneLogin();
        });
        /***手机注册**/
        registerLlPhone.setOnClickListener(v -> {
            this.dismiss();
            showPhoneRegis();
        });
        /***微信登陆**/
        loginImg.setOnClickListener(v -> {
            this.dismiss();
            UserKit.loginWeinXin();
        });
    }


    private void showPhoneLogin() {
        OpenPhone openPhone = new OpenPhone();
        openPhone.setShowBottom(true);
        openPhone.myCenterFragment = myCenterFragment;
//        openPhone.setCancelable(false);
//        openPhone.setOutCancel(false);
        openPhone.show(getFragmentManager());
    }

    private void showPhoneRegis() {
        ToolsKit.go(getActivity(), PhoneRegisActivity.class, null);
    }


}
